package br.com.tcc.systemdx.persistence;

import java.util.List;

import org.hibernate.criterion.Criterion;

import br.com.tcc.systemdx.commons.persistence.CriteriaTransformer;
import br.com.tcc.systemdx.commons.persistence.GenericDAO;
import br.com.tcc.systemdx.domain.BaseEntity;

public interface AbstractEntityDAO<T  extends BaseEntity> extends GenericDAO<T, Long> {
	public static final Long INVALID_ID = new Long(-1);
	
	T findById(Long id);
	T findForUpdate(Long id);
	T findById(Long id, CriteriaTransformer criteriaTransformer);
	T refresh(T entity);
	
	/**
     * 
     * @param maxResults
     * @param firstResult
     * @param sortPropertyName
     * @param ascending
     * @param criterion
     * @return
     */
    List<T> findByCriteria(int maxResults, int firstResult,
			String sortPropertyName, boolean ascending, Criterion... criterion);
    
    List<T> findByCriteria(Criterion... criterion);
    List<T> findByCriteria(CriteriaTransformer transformer, Criterion... criterion);
    /**
     * 
     * @return
     */
    List<T> findAll();
    
	/**
	 * 
	 * @param criterion
	 * @return
	 */
	int countByCriteria(Criterion... criterion);
	    
	T salvar(T instance) throws Exception;
	
	List<T> salvar(List<T> instances) throws Exception;
	
	void deletar(Long id) throws Exception;

	void deletar(T entidade) throws Exception;
	
	void disconnect(T entity);

}
